<?php

namespace App\Http\Controllers\admin;

use App\Dao\TaskDao;
use App\Dao\TaskLogDao;
use App\Services\Code;

class TasksController extends BaseController
{
    public function tasks(){
        if(getIsHasPage()){
            $params = request()->all();
            return Code::message('',200,TaskDao::pages($params));
        }
        return  view('admin.tasks.tasks');
    }

    public function add(){
        if(isPost()){
            $params = request()->all();
            TaskDao::add($params);
            return Code::message('',200);
        }
        return  view('admin.tasks.add');
    }

    public function edit(){
        $params = request()->all();
        if(isPost()){
            TaskDao::edit($params);
            return Code::message('',200);
        }
        $info = TaskDao::info($params);
        return  view('admin.tasks.edit',[
            'info'=>$info
        ]);
    }

    public function del(){
        TaskDao::delete(request()->all());
        return Code::message('删除成功',200);
    }


    public function taskLogs()
    {
        if(getIsHasPage()){
            return Code::message('',200,TaskLogDao::pages(request()->all()));
        }
        return  view('admin.tasks.logs');
    }
}
